package cn.wenlihelp.model;


import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

@Data
@Accessors(chain = true)
public class ResultPage<T> {
    private int code;
    private long count;
    private String msg;
    private List<T> data;
    private int page;
    private int pageSize;


    public static <T> ResultPage<T> success(String msg,long count,List<T> data,int page,int pageSize){
        return new ResultPage<T>().setCode(0).setMsg(msg).setCount(count).setData(data).setPage(page).setPageSize(pageSize);
    }
    public static <T> ResultPage<T> success(long count,List<T> data,int page,int pageSize){
        return success("成功",count,data,page,pageSize);
    }
//    public static <T> ResultPage<T> success(List<T> data){
//        //return success("成功",data != null ? data.size():0,data);
//        return success("成功", Optional.ofNullable(data).map(List::size).orElse(0),data);
//    }

}
